package cn.itcast.bos.web.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;

import com.opensymphony.xwork2.ActionContext;

import cn.itcast.bos.domain.base.TakeTime;
import cn.itcast.bos.service.base.TakeTimeService;

@ParentPackage("json-default")
@Namespace("/")
@Action
@Scope("prototype")
public class TakeTimeAction extends BaseAction<TakeTime> {

	@Autowired
	private TakeTimeService takeTimeService;
	
	@Action(value="findTakeTimeByPage",results={@Result(name="success",type="json")})
	public String findAllByPage(){
		Pageable pageable = new PageRequest(page - 1 , rows);
		Page<TakeTime> pagedatas = takeTimeService.findAll(pageable);
		
		pushToValueStack(pagedatas);
		return SUCCESS;
	}
	@Action(value="findTakeTime",results={@Result(name="success",type="json")})
	public String findAll(){
		List<TakeTime> list = takeTimeService.findAllTakeTime();
		ActionContext.getContext().getValueStack().push(list);
		return SUCCESS;
	}
}
